package com.zsy.controller;

import com.zsy.entity.Project;
import com.zsy.service.IProjectService;
import com.zsy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/research")
public class ProjectController {

    @Autowired
    private IProjectService ipjs;

    //获取所有项目
    @GetMapping("/selectProject")
    public Result getAllProject(Project project){
        return ipjs.getAllProject(project);
    }

    //获取项目通过前端所传的数据
    @PostMapping("/selectProjectByInformation")
    public Result getProject(Project project){
        return ipjs.getProject(project);
    }

    //添加项目
    @PostMapping("/addProject")
    public Result addProject(Project project){
        return ipjs.addProject(project);
    }

    //删除项目
    @PostMapping("/deleteProject")
    public Result deleteProject(Integer projectId){
        return ipjs.deleteProject(projectId);
    }

    //修改项目
    @PostMapping("/updateProject")
    public Result updateProject(Project project){
        return ipjs.updateProject(project);
    }

    // 批量删除（修改状态）
    @PostMapping("/deleteProjectByIds")
    public Result<String> deleteProjectByIds(Integer[] projectIds){
        return ipjs.updateOrdersStatusToZero(projectIds);
    }
}
